package com.ruoyi.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.domain.SleOrderPro;
import com.ruoyi.mes.service.ISleOrderProService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单产品联系Controller
 * 
 * @author ruoyi
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/mes/orderPro")
public class SleOrderProController extends BaseController
{
    @Autowired
    private ISleOrderProService sleOrderProService;

    /**
     * 查询订单产品联系列表
     */
    @PreAuthorize("@ss.hasPermi('mes:orderPro:list')")
    @GetMapping("/list")
    public TableDataInfo list(SleOrderPro sleOrderPro)
    {
        startPage();
        List<SleOrderPro> list = sleOrderProService.selectSleOrderProList(sleOrderPro);
        return getDataTable(list);
    }

    /**
     * 导出订单产品联系列表
     */
    @PreAuthorize("@ss.hasPermi('mes:orderPro:export')")
    @Log(title = "订单产品联系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SleOrderPro sleOrderPro)
    {
        List<SleOrderPro> list = sleOrderProService.selectSleOrderProList(sleOrderPro);
        ExcelUtil<SleOrderPro> util = new ExcelUtil<SleOrderPro>(SleOrderPro.class);
        util.exportExcel(response, list, "订单产品联系数据");
    }

    /**
     * 获取订单产品联系详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:orderPro:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sleOrderProService.selectSleOrderProById(id));
    }

    /**
     * 新增订单产品联系
     */
    @PreAuthorize("@ss.hasPermi('mes:orderPro:add')")
    @Log(title = "订单产品联系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SleOrderPro sleOrderPro)
    {
        return toAjax(sleOrderProService.insertSleOrderPro(sleOrderPro));
    }

    /**
     * 修改订单产品联系
     */
    @PreAuthorize("@ss.hasPermi('mes:orderPro:edit')")
    @Log(title = "订单产品联系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SleOrderPro sleOrderPro)
    {
        return toAjax(sleOrderProService.updateSleOrderPro(sleOrderPro));
    }

    /**
     * 删除订单产品联系
     */
    @PreAuthorize("@ss.hasPermi('mes:orderPro:remove')")
    @Log(title = "订单产品联系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sleOrderProService.deleteSleOrderProByIds(ids));
    }
}
